//
//  FGNavigationController.swift
//  微博
//
//  Created by 陈金田 on 16/12/29.
//  Copyright © 2016年 陈金田. All rights reserved.
//

import UIKit

class FGNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //隐藏默认的nav
        navigationBar.isHidden = true
        

    
        //viewcontroller是被push的控制器，设置左侧按钮，做为返回按钮
        func pushViewController(viewController: UIViewController, animated: Bool){
            print(viewController)
            
            if childViewControllers.count > 0 {
                viewController.hidesBottomBarWhenPushed = true
            }
 
            if let vc = viewController as? FGBaseViewController{
                vc.navItem.leftBarButtonItem = UIBarButtonItem(title: "返回", target: self, action: #selector(popToParent))
            }

            super.pushViewController(viewController, animated: true)
        }
 
    }

    func popToParent(){
        popViewController(animated: true)
    }

}
